<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>会员管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		function syn(){
			var wxid = $('#wxid').val();
			var appname = $("#wxid").find("option:selected").text();
			if (wxid != ""){
				$.get("${ctx}/wx/wxUser/key/" + wxid, function(data){
					if (data == "true"){
						alertx("同步“" + appname + "”微信公众号用户成功。", page);
					}else{
						alertx("同步“" + appname + "”微信公众号用户失败。");
					}
				});
			}else{
				alertx("请选择一个公众号！");
			}
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/wx/wxUser/">会员列表</a></li>
		<shiro:hasPermission name="wx:wxUser:edit"><li><a href="${ctx}/wx/wxUser/form">会员添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="wxUser" action="${ctx}/wx/wxUser/list" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li>
				<form:select path="wxid" class="input-medium">
					<form:option value="" label="请选择"/>
					<form:options items="${fnc:getAllWxConfig()}" itemLabel="appname" itemValue="id" htmlEscape="false"/>
				</form:select>
			</li>
			<li><label>微信昵称：</label>
				<form:input path="nickname" htmlEscape="false" maxlength="255" class="input-medium"/>
			</li>
			<li class="btns">
			<a class="btn btn-primary" href="javascript:syn();"  onclick="return confirmx('确认要同步数据吗吗？', this.href)"><i class="icon-play"></i>同步</a>
			<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>openid</th>
				<th>unionid</th>
				<th>微信昵称</th>
				<th>是否关注</th>
				<th>关注时间</th>
				<th>性别</th>
				<th>更新时间</th>
				<th>备注信息</th>
				<shiro:hasPermission name="wx:wxUser:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="wxUser">
			<tr>
				<td><a href="${ctx}/wx/wxUser/form?id=${wxUser.id}">
					${wxUser.openid}
				</a></td>
				<td>
					${wxUser.unionid}
				</td>
				<td>
					<img src="${wxUser.headimgurl}" width="25" height="25"> ${wxUser.nickname}
				</td>
				<td>
					${wxUser.subscribe}
				</td>
				<td>
					${wxUser.subscribeat}
				</td>
				<td>
					${wxUser.sex}
				</td>
				<td>
					<fmt:formatDate value="${wxUser.updateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					${wxUser.remarks}
				</td>
				<shiro:hasPermission name="wx:wxUser:edit"><td>
    				<a href="${ctx}/wx/wxUser/form?id=${wxUser.id}">修改</a>
					<a href="${ctx}/wx/wxUser/delete?id=${wxUser.id}" onclick="return confirmx('确认要删除该会员吗？', this.href)">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>